package org.nbict.iot.trident.mogo.state;

import org.apache.storm.task.IMetricsContext;
import org.apache.storm.trident.state.State;
import org.apache.storm.trident.state.StateFactory;

import java.util.Map;

/**
 * mongo state 工厂类
 * Created by songseven on 18/6/25.
 */
public class MongoStateFactory implements StateFactory {
    private MongoState.Options options;

    public MongoStateFactory(MongoState.Options options) {
        this.options = options;
    }

    @Override
    public State makeState(Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
        MongoState state = new MongoState(conf, this.options);
        state.prepare();
        return state;
    }
}
